package com.example.text2.adapter;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

/**
 * Created by 段傅华 on 2018/12/13.
 */

public class VpAdapter extends FragmentStatePagerAdapter {
    private final ArrayList<Fragment> mFragments;
    private final ArrayList<String> mTitls;

    public VpAdapter(FragmentManager fm, ArrayList<Fragment> fragments, ArrayList<String> titles) {
        super(fm);
        this.mFragments=fragments;
        this.mTitls=titles;
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments.get(position);
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitls.get(position);
    }
}
